package com.dp.mallchat.common.user.controller;


import com.dp.mallchat.common.common.domain.dto.RequestInfo;
import com.dp.mallchat.common.common.domain.vo.req.CursorPageBaseReq;
import com.dp.mallchat.common.common.domain.vo.resp.ApiResult;
import com.dp.mallchat.common.common.domain.vo.resp.CursorPageBaseResp;
import com.dp.mallchat.common.common.domain.vo.resp.PageBaseResp;
import com.dp.mallchat.common.common.utils.RequestHolder;
import com.dp.mallchat.common.user.domain.user.req.ApplyApprovalReq;
import com.dp.mallchat.common.user.domain.user.req.FriendDeleteReq;
import com.dp.mallchat.common.user.domain.user.resp.UserApplyPageResp;
import com.dp.mallchat.common.user.domain.user.resp.UserFriendResp;
import com.dp.mallchat.common.user.service.UserFriendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.validation.Valid;

/**
 * <p>
 * 用户联系人表 前端控制器
 * </p>
 *
 * @author <a href="https://gitee.com/baiDP">adu</a>
 * @since 2024-06-19
 */
@RestController
@RequestMapping("/capi/user/friend")
@Api(value = "用户好友相关接口", tags = "用户好友相关接口")
public class UserFriendController {

    @Autowired
    private UserFriendService userFriendService;

    @ApiOperation("用户好友列表")
    @GetMapping("/page")
    public ApiResult<CursorPageBaseResp<UserFriendResp>> page(@Valid CursorPageBaseReq cursorPageBaseReq){
        RequestInfo requestInfo = RequestHolder.getThreadLocal();
        return ApiResult.success(userFriendService.friendList(requestInfo.getUid(),cursorPageBaseReq));
    }


    @ApiOperation("刪除好友")
    @DeleteMapping
    public ApiResult<Void> deleteFriend(@Valid @RequestBody FriendDeleteReq req) {
        RequestInfo requestInfo = RequestHolder.getThreadLocal();
        userFriendService.deleteFriend(requestInfo.getUid(), req.getTargetUid());
        return ApiResult.success();
    }

}

